package com.xiangge.array;


public class Kehou {
    public static void main(String[] args) {
        int[] arr = {5,12,90,18,77,76,45,28,59,72};
//        max1(arr);
//        findindex1(arr);
//        re1(arr);
//        de(arr);
//        in222(arr);

    }

    private static void in222(int[] arr) {
        int[] arr2 = new int[arr.length + 1];
        for (int i = 0; i <= arr2.length-1; i++) {
            if (i<2){
                arr2[i] = arr[i];
            }else if (i==2){
                arr2[i] = 222;
            }else {
                arr2[i] = arr[i-1];
            }
        }
        System.out.println("插入后：");
        for (int i : arr2) {
            System.out.print(i + " ");
        }
    }

    private static void de(int[] arr) {
        for (int i = 2; i < arr.length - 1; i++) {
            arr[i] = arr[i+1];
        }
        arr[arr.length-1] = 0;
        for (int i : arr) {
            System.out.print(i+" ");
        }
    }



    private static void re1(int[] arr) {
        int[] arr2 = new int[arr.length];
        for (int i = arr.length - 1; i >= 0; i--) {
            arr2[arr.length-i-1] = arr[i];
        }
        for (int i : arr2) {
            System.out.print(i+" ");
        }
    }


    private static void findindex1(int[] arr) {
        for (int i = -1; i < arr.length-1; i++) {
            if (arr[i]==59){
                System.out.println("59在数组中的索引为"+i);
            }else {
                System.out.println("59不在此数组中");
            }
        }
    }

    private static void max1(int[] arr) {
        int max = 0;
        for (int i = 0; i < arr.length-1; i++) {
            if (max< arr[i]){
                max = arr[i];
            }else {
                max = max;
            }
        }
        System.out.println("max = " + max);
    }
}
